#include "dbtabrecordclass.h"

const QLatin1String DBTabRecordClass::TAB_NAME = QLatin1String("recordClass");
const char* DBTabRecordClass::_UUID = "uuid";
const char* DBTabRecordClass::_DATE = "date";
const char* DBTabRecordClass::_TIME = "time";
const char* DBTabRecordClass::_RECORD_NO = "recordNo";
const char* DBTabRecordClass::_PRODUCT_NAME = "prtName";
const char* DBTabRecordClass::_BARCODE = "barcode";
const char* DBTabRecordClass::_PRODUCT_BRAND = "brand";
const char* DBTabRecordClass::_NET = "net";
const char* DBTabRecordClass::_TARE = "tare";
const char* DBTabRecordClass::_GROSS = "gross";
const char* DBTabRecordClass::_RANGE = "range";
const char* DBTabRecordClass::_CHKRESULT = "chkResult";
const char* DBTabRecordClass::_USER = "user";


const DBTabRecordClass::ColumnInfo DBTabRecordClass::mColumnTab[] =
{
    [INDEX_ID]  =  {DBTabRecordClass::_ID,"integer primary key AUTOINCREMENT"},
    [INDEX_UUID] =  {DBTabRecordClass::_UUID,"varchar"},
    [INDEX_DATE]  =  {DBTabRecordClass::_DATE,"date"},
    [INDEX_TIME]=  {DBTabRecordClass::_TIME,"time"},
    [INDEX_RECORD_NO] = {DBTabRecordClass::_RECORD_NO,"integer"},
    [INDEX_PRODUCT_NAME] = {DBTabRecordClass::_PRODUCT_NAME,"varchar"},
    [INDEX_BARCODE] = {DBTabRecordClass::_BARCODE,"varchar"},
    [INDEX_PRODUCT_BRAND] = {DBTabRecordClass::_PRODUCT_BRAND,"varchar"},
    [INDEX_NET] = {DBTabRecordClass::_NET,"float"},
    [INDEX_TARE] = {DBTabRecordClass::_TARE,"float"},
    [INDEX_GROSS] = {DBTabRecordClass::_GROSS,"float"},
    [INDEX_RANGE] = {DBTabRecordClass::_RANGE,"varchar"},
    [INDEX_CHKRESULT] = {DBTabRecordClass::_CHKRESULT,"integer"},
    [INDEX_USER] = {DBTabRecordClass::_USER,"varchar"},
    [INDEX_END] = {nullptr,nullptr}
};

void DBTabRecordClass::createTab(QSqlDatabase &db)
{
    DBTabBase::createTab(mTabName,mColumnTab,db);
}

const char *DBTabRecordClass::getColumnName(int index)
{
    if(index<INDEX_END){
        return mColumnTab[index].columnName;
    }
    return "";
}

DBTabRecordClass::DBTabRecordClass():DBTabBase(TAB_NAME)
{

}

